104. Araxis Merge File Comparison Report

Produced by Araxis Merge on 2020-08-14 00:01:34 +0000. See www.araxis.com for information about Merge. This report uses XHTML and CSS2, and is best viewed with a modern standards-compliant browser. For optimum results when printing this report, use landscape orientation and enable printing of background images and colours in your browser.

104.1 Files compared

#LocationFileLast Modified
1Porto v3.2.3/Magento 2.x/Porto Theme/app/code/Mageplaza/LayeredNavigation/view/frontend/web/js/viewlayer.js2018-10-28 22:42:26 +0000
2Porto v3.2.4/Magento 2.x/Porto Theme/app/code/Mageplaza/LayeredNavigation/view/frontend/web/js/viewlayer.js2020-08-11 09:17:16 +0000

104.2 Comparison summary

DescriptionBetween
Files 1 and 2
Text BlocksLines
Unchanged11592
Changed516
Inserted434
Removed11

104.3 Comparison options

WhitespaceConsecutive whitespace is treated as a single space
Character caseDifferences in character case are significant
Line endingsDifferences in line endings (CR and LF characters) are ignored
CR/LF charactersNot shown in the comparison detail
Active line-pairing rules

104.4 Active regular expressions

No regular expressions were active.

104.5 Comparison detail

1 /** 1 /**
2  * Mageplaza 2  * Mageplaza
3  * 3  *
4  * NOTICE OF LICENSE 4  * NOTICE OF LICENSE
5  * 5  *
6  * This source file is subject to the Mageplaza.com license sliderConfig is 6  * This source file is subject to the Mageplaza.com license sliderConfig is
7  * available through the world-wide-web at this URL: 7  * available through the world-wide-web at this URL:
8  * https://www.mageplaza.com/LICENSE.txt 8  * https://www.mageplaza.com/LICENSE.txt
9  * 9  *
10  * DISCLAIMER 10  * DISCLAIMER
11  * 11  *
12  * Do not edit or add to this file if you wish to upgrade this extension to newer 12  * Do not edit or add to this file if you wish to upgrade this extension to newer
13  * version in the future. 13  * version in the future.
14  * 14  *
15  * @category    Mageplaza 15  * @category    Mageplaza
16  * @package     Mageplaza_LayeredNavigation 16  * @package     Mageplaza_LayeredNavigation
17  * @copyright   Copyright (c) Mageplaza (https://www.mageplaza.com/) 17  * @copyright   Copyright (c) Mageplaza (https://www.mageplaza.com/)
18  * @license     https://www.mageplaza.com/LICENSE.txt 18  * @license     https://www.mageplaza.com/LICENSE.txt
19  */ 19  */
20  20 
21 define([ 21 define([
22     'jquery', 22     'jquery',
23     'Mageplaza_AjaxLayer/js/action/submit-filter', 23     'Mageplaza_AjaxLayer/js/action/submit-filter',
24     'Magento_Catalog/js/price-utils', 24     'Magento_Catalog/js/price-utils',
25     'jquery/ui', 25     'jquery/ui',
26     'accordion', 26     'accordion',
27     'productListToolbarForm' 27     'productListToolbarForm'
28 ], function ($, submitFilterAction, ultil) { 28 ], function ($, submitFilterAction, ultil) {
29     "use strict"; 29     "use strict";
30  30 
31     $.widget('mageplaza.layer', $.mage.accordion, { 31     $.widget('mageplaza.layer', $.mage.accordion, {
32         options: { 32         options: {
33             openedState: 'active', 33             openedState: 'active',
34             collapsible: true, 34             collapsible: true,
35             multipleCollapsible: true, 35             multipleCollapsible: true,
36             animate: 200, 36             animate: 200,
37             mobileShopbyElement: '#layered-filter-block .filter-title [data-role=title]', 37             mobileShopbyElement: '#layered-filter-block .filter-title [data-role=title]',
38             collapsibleElement: '[data-role=ln_collapsible]', 38             collapsibleElement: '[data-role=ln_collapsible]',
39             header: '[data-role=ln_title]', 39             header: '[data-role=ln_title]',
40             content: '[data-role=ln_content]', 40             content: '[data-role=ln_content]',
41             isCustomerLoggedIn: false, 41             isCustomerLoggedIn: false,
42             isAjax: true, 42             isAjax: true,
43             params: [], 43             params: [],
44             active: [], 44             active: [],
45             checkboxEl: 'input[type=checkbox]
',
 45             checkboxEl: 'input[type=checkbox], input[type=radio]',
46             sliderElementPrefix: '#ln_slider_', 46             sliderElementPrefix: '#ln_slider_',
47             sliderTextElementPrefix: '#ln_slider_text_' 47             sliderTextElementPrefix: '#ln_slider_text_'
48         }, 48         },
49  49 
50         _create: function () { 50         _create: function () {
51             this.initActiveItems(); 51             this.initActiveItems();
52  52 
53             this._super(); 53             this._super();
54  54 
55             this.initProductListUrl(); 55             this.initProductListUrl();
56             this.initObserve(); 56             this.initObserve();
57             this.initSlider(); 57             this.initSlider();
58             this.initWishlistCompare(); 58             this.initWishlistCompare();
    59             this.selectedAttr();
59         }, 60         },
60  61 
61         initActiveItems: function () { 62         initActiveItems: function () {
62             var layerActives = this.options.active, 63             var layerActives = this.options.active,
63                 actives = []; 64                 actives = [];
64  65 
65             if (typeof window.layerActiveTabs !== 'undefined') { 66             if (typeof window.layerActiveTabs !== 'undefined') {
66                 layerActives = window.layerActiveTabs; 67                 layerActives = window.layerActiveTabs;
67             } 68             }
68             if (layerActives.length) { 69             if (layerActives.length) {
69                 this.element.find('.filter-options-item').each(function (index) { 70                 this.element.find('.filter-options-item').each(function (index) {
70                     if (~$.inArray($(this).attr('attribute'), layerActives)) { 71                     if (~$.inArray($(this).attr('attribute'), layerActives)) {
71                         actives.push(index); 72                         actives.push(index);
72                     } 73                     }
73                 }); 74                 });
74             } 75             }
75  76 
76             this.options.active = actives; 77             this.options.active = actives;
77  78 
78             return this; 79             return this;
79         }, 80         },
80  81 
81         initProductListUrl: function () { 82         initProductListUrl: function () {
82             var isProcessToolbar = false, 83             var isProcessToolbar = false,
83                 isAjax = this.options.isAjax; 84                 isAjax = this.options.isAjax;
84             $.mage.productListToolbarForm.prototype.changeUrl = function (paramName, paramValue, defaultValue) { 85             $.mage.productListToolbarForm.prototype.changeUrl = function (paramName, paramValue, defaultValue) {
85                 if (isProcessToolbar) { 86                 if (isProcessToolbar) {
86                     return; 87                     return;
87                 } 88                 }
88                 if (isAjax) { 89                 if (isAjax) {
89                     isProcessToolbar = true; 90                     isProcessToolbar = true;
90                 } 91                 }
91  92 
92                 var urlPaths = this.options.url.split('?'), 93                 var urlPaths = this.options.url.split('?'),
93                     baseUrl = urlPaths[0], 94                     baseUrl = urlPaths[0],
94                     urlParams = urlPaths[1] ? urlPaths[1].split('&') : [], 95                     urlParams = urlPaths[1] ? urlPaths[1].split('&') : [],
95                     paramData = {}, 96                     paramData = {},
96                     parameters; 97                     parameters;
97                 for (var i = 0; i < urlParams.length; i++) { 98                 for (var i = 0; i < urlParams.length; i++) {
98                     parameters = urlParams[i].split('='); 99                     parameters = urlParams[i].split('=');
99                     paramData[parameters[0]] = parameters[1] !== undefined 100                     paramData[parameters[0]] = parameters[1] !== undefined
100                         ? window.decodeURIComponent(parameters[1].replace(/\+/g, '%20')) 101                         ? window.decodeURIComponent(parameters[1].replace(/\+/g, '%20'))
101                         : ''; 102                         : '';
102                 } 103                 }
103                 paramData[paramName] = paramValue; 104                 paramData[paramName] = paramValue;
104                 if (paramValue === defaultValue) { 105                 if (paramValue === defaultValue) {
105                     delete paramData[paramName]; 106                     delete paramData[paramName];
106                 } 107                 }
107                 paramData = $.param(paramData); 108                 paramData = $.param(paramData);
108                 if (isAjax) { 109                 if (isAjax) {
109                     submitFilterAction(baseUrl + (paramData.length ? '?' + paramData : '')); 110                     submitFilterAction(baseUrl + (paramData.length ? '?' + paramData : ''));
110                 } 111                 else location.href = baseUrl + (paramData.length ? '?' + paramData : '');
111                 
else location.href = baseUrl + (paramData.length ? '?' + paramData : '');
    
112             } 112             }
113         }, 113         },
114  114 
115         initObserve: function () { 115         initObserve: function () {
116             var self = this; 116             var self = this;
117             var isAjax = this.options.isAjax; 117             var isAjax = this.options.isAjax;
118  118 
    119             // fix browser back, forward button
    120             if (typeof window.history.replaceState === "function") {
    121                 window.history.replaceState({url: document.URL}, document.title);
    122 
    123                 setTimeout(function () {
    124                     window.onpopstate = function (e) {
    125                         if (e.state) {
    126                             submitFilterAction(e.state.url, 1);
    127                         }
    128                     };
    129                 }, 0)
    130             }
    131 
119             var pageElements = $('#layer-product-list').find('.pages a'); 132             var pageElements = $('#layer-product-list').find('.pages a');
120             pageElements.each(function () { 133             pageElements.each(function () {
121                 var el = $(this), 134                 var el = $(this),
122                     link = self.checkUrl(el.prop('href')); 135                     link = self.checkUrl(el.prop('href'));
123                 if (!link) { 136                 if (!link) {
124                     return; 137                     return;
125                 } 138                 }
126  139 
127                 el.bind('click', function (e) { 140                 el.bind('click', function (e) {
128                     e.stopPropagation(); 141                     e.stopPropagation();
129                     e.preventDefault(); 142                     e.preventDefault();
130                     if (isAjax) { 143                     if (isAjax) {
131                         submitFilterAction(link); 144                         submitFilterAction(link);
132                     } 145                     else location.href = link;
133                     
else location.href = link;
    
134                 }) 146                 })
135             }); 147             });
136  148 
137             var currentElements = this.element.find('.filter-current a, .filter-actions a'); 149             var currentElements = this.element.find('.filter-current a, .filter-actions a');
138             currentElements.each(function (index) { 150             currentElements.each(function (index) {
139                 var el = $(this), 151                 var el = $(this),
140                     link = self.checkUrl(el.prop('href')); 152                     link = self.checkUrl(el.prop('href'));
141                 if (!link) { 153                 if (!link) {
142                     return; 154                     return;
143                 } 155                 }
144  156 
145                 el.bind('click', function (e) { 157                 el.bind('click', function (e) {
146                     e.stopPropagation(); 158                     e.stopPropagation();
147                     e.preventDefault(); 159                     e.preventDefault();
148                     if (isAjax) { 160                     if (isAjax) {
149                         submitFilterAction(link); 161                         submitFilterAction(link);
    162                     } else {
    163                         location.href = link;
150                     } 164                     }
151                     else location.href = link;    
152                 }); 165                 });
153             }); 166             });
154  167 
155             var optionElements = this.element.find('.filter-options a'); 168             var optionElements = this.element.find('.filter-options a');
156             optionElements.each(function (index) { 169             optionElements.each(function (index) {
157                 var el = $(this), 170                 var el = $(this),
158                     link = self.checkUrl(el.prop('href')); 171                     link = self.checkUrl(el.prop('href'));
159                 if (!link) { 172                 if (!link) {
160                     return; 173                     return;
161                 } 174                 }
162  175 
163                 el.bind('click', function (e) { 176                 el.bind('click', function (e) {
164                     if (el.hasClass('swatch-option-link-layered')) { 177                     if (el.hasClass('swatch-option-link-layered')) {
165                         self.selectSwatchOption(el); 178                         self.selectSwatchOption(el);
166                     } else { 179                     } else {
167                         var checkboxEl = el.siblings(self.options.checkboxEl); 180                         var checkboxEl = el.siblings(self.options.checkboxEl);
168                         checkboxEl.prop('checked', !checkboxEl.prop('checked')); 181                         checkboxEl.prop('checked', !checkboxEl.prop('checked'));
169                     } 182                     }
170  183 
171                     e.stopPropagation(); 184                     e.stopPropagation();
172                     e.preventDefault(); 185                     e.preventDefault();
173                     self.ajaxSubmit(link); 186                     self.ajaxSubmit(link);
174                 }); 187                 });
175  188 
176                 var checkbox = el.siblings(self.options.checkboxEl); 189                 var checkbox = el.siblings(self.options.checkboxEl);
177                 checkbox.bind('click', function (e) { 190                 checkbox.bind('click', function (e) {
178                     e.stopPropagation(); 191                     e.stopPropagation();
179                     self.ajaxSubmit(link); 192                     self.ajaxSubmit(link);
180                 }); 193                 });
181             }); 194             });
182  195 
183             var swatchElements = this.element.find('.swatch-attribute'); 196             var swatchElements = this.element.find('.swatch-attribute');
184             swatchElements.each(function (index) { 197             swatchElements.each(function (index) {
185                 var el = $(this); 198                 var el = $(this);
186                 var attCode = el.attr('attribute-code'); 199                 var attCode = el.attr('attribute-code');
187                 if (attCode) { 200                 if (attCode) {
188                     if (self.options.params.hasOwnProperty(attCode)) { 201                     if (self.options.params.hasOwnProperty(attCode)) {
189                         var attValues = self.options.params[attCode].split(","); 202                         var attValues = self.options.params[attCode].split(",");
190                         var swatchOptions = el.find('.swatch-option'); 203                         var swatchOptions = el.find('.swatch-option');
191                         swatchOptions.each(function (option) { 204                         swatchOptions.each(function (option) {
192                             var elOption = $(this); 205                             var elOption = $(this);
193                             if ($.inArray(elOption.attr('option-id'), attValues) !== -1) { 206                             if ($.inArray(elOption.attr('option-id'), attValues) !== -1) {
194                                 elOption.addClass('selected'); 207                                 elOption.addClass('selected');
195                             } 208                             }
196                         }); 209                         });
197                     } 210                     }
198                 } 211                 }
199             }); 212             });
200         }, 213         },
201  214 
202         selectSwatchOption: function (el) { 215         selectSwatchOption: function (el) {
203             var childEl = el.find('.swatch-option'); 216             var childEl = el.find('.swatch-option');
204             if (childEl.hasClass('selected')) { 217             if (childEl.hasClass('selected')) {
205                 childEl.removeClass('selected'); 218                 childEl.removeClass('selected');
206             } else { 219             } else {
207                 childEl.addClass('selected'); 220                 childEl.addClass('selected');
208             } 221             }
209         }, 222         },
210  223 
211         initSlider: function () { 224         initSlider: function () {
212             var self = this, 225             var self = this,
213                 slider = this.options.slider; 226                 slider = this.options.slider;
214  227 
215             for (var code in slider) { 228             for (var code in slider) {
216                 if (slider.hasOwnProperty(code)) { 229                 if (slider.hasOwnProperty(code)) {
217                     var sliderConfig = slider[code], 230                     var sliderConfig = slider[code],
218                         sliderElement = self.element.find(this.options.sliderElementPrefix + code), 231                         sliderElement = self.element.find(this.options.sliderElementPrefix + code),
219                         priceFormat = sliderConfig.hasOwnProperty('priceFormat') ? JSON.parse(sliderConfig.priceFormat) : null; 232                         priceFormat = sliderConfig.hasOwnProperty('priceFormat') ? JSON.parse(sliderConfig.priceFormat) : null;
220  233 
221                     if (sliderElement.length) { 234                     if (sliderElement.length) {
222                         sliderElement.slider({ 235                         sliderElement.slider({
223                             range: true, 236                             range: true,
224                             min: sliderConfig.minValue, 237                             min: sliderConfig.minValue,
225                             max: sliderConfig.maxValue, 238                             max: sliderConfig.maxValue,
226                             values: [sliderConfig.selectedFrom, sliderConfig.selectedTo], 239                             values: [sliderConfig.selectedFrom, sliderConfig.selectedTo],
227                             slide: function (event, ui) { 240                             slide: function (event, ui) {
228                                 self.displaySliderText(code, ui.values[0], ui.values[1], priceFormat); 241                                 self.displaySliderText(code, ui.values[0], ui.values[1], priceFormat);
229                             }, 242                             },
230                             change: function (event, ui) { 243                             change: function (event, ui) {
231                                 self.ajaxSubmit(self.getSliderUrl(sliderConfig.ajaxUrl, ui.values[0], ui.values[1])); 244                                 self.ajaxSubmit(self.getSliderUrl(sliderConfig.ajaxUrl, ui.values[0], ui.values[1]));
232                             } 245                             }
233                         }); 246                         });
234                     } 247                     }
235                     self.displaySliderText(code, sliderConfig.selectedFrom, sliderConfig.selectedTo, priceFormat); 248                     self.displaySliderText(code, sliderConfig.selectedFrom, sliderConfig.selectedTo, priceFormat);
236                 } 249                 }
237             } 250             }
238         }, 251         },
239  252 
240         displaySliderText: function (code, from, to, format) { 253         displaySliderText: function (code, from, to, format) {
241             var textElement = this.element.find(this.options.sliderTextElementPrefix + code); 254             var textElement = this.element.find(this.options.sliderTextElementPrefix + code);
242             if (textElement.length) { 255             if (textElement.length) {
243                 if (format !== null) { 256                 if (format !== null) {
244                     from = this.formatPrice(from, format); 257                     from = this.formatPrice(from, format);
245                     to = this.formatPrice(to, format); 258                     to = this.formatPrice(to, format);
246                 } 259                 }
247  260 
248                 textElement.html(from + ' - ' + to); 261                 textElement.html(from + ' - ' + to);
249             } 262             }
250         }, 263         },
251  264 
252         getSliderUrl: function (url, from, to) { 265         getSliderUrl: function (url, from, to) {
253             return url.replace('from-to', from + '-' + to); 266             return url.replace('from-to', from + '-' + to);
254         }, 267         },
255  268 
256         formatPrice: function (value, format) { 269         formatPrice: function (value, format) {
257             return ultil.formatPrice(value, format); 270             return ultil.formatPrice(value, format);
258         }, 271         },
259  272 
260         ajaxSubmit: function (submitUrl) { 273         ajaxSubmit: function (submitUrl) {
261             var isAjax = this.options.isAjax; 274             var isAjax = this.options.isAjax;
262             this.element.find(this.options.mobileShopbyElement).trigger('click'); 275             this.element.find(this.options.mobileShopbyElement).trigger('click');
263  276 
264             if (isAjax) { 277             if (isAjax) {
265                 return submitFilterAction(submitUrl); 278                 return submitFilterAction(submitUrl);
266             } 279             }
267             location.href = submitUrl; 280             location.href = submitUrl;
268         }, 281         },
269  282 
270         checkUrl: function (url) { 283         checkUrl: function (url) {
271             var regex = /(http|https):\/\/(\w+:{0,1}\w*)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%!\-\/]))?/; 284             var regex = /(http|https):\/\/(\w+:{0,1}\w*)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%!\-\/]))?/;
272  285 
273             return regex.test(url) ? url : null; 286             return regex.test(url) ? url : null;
274         }, 287         },
275  288 
276         //Handling 'add to wishlist' & 'add to compare' event 289         //Handling 'add to wishlist' & 'add to compare' event
277         initWishlistCompare: function () { 290         initWishlistCompare: function () {
278             var isAjax = this.options.isAjax; 291             var isAjax = this.options.isAjax;
279             var isCustomerLoggedIn = this.options.isCustomerLoggedIn, 292             var isCustomerLoggedIn = this.options.isCustomerLoggedIn,
280                 elClass = 'a.action.tocompare' + (isCustomerLoggedIn ? ',a.action.towishlist' : ''); 293                 elClass = 'a.action.tocompare' + (isCustomerLoggedIn ? ',a.action.towishlist' : '');
281             $(elClass).each(function () { 294             $(elClass).each(function () {
282                 var el = $(this); 295                 var el = $(this);
283                 $(el).bind('click', function (e) { 296                 $(el).bind('click', function (e) {
284                     var dataPost = $(el).data('post'), 297                     var dataPost = $(el).data('post'),
285                         formKey = $('input[name="form_key"]').val(); 298                         formKey = $('input[name="form_key"]').val();
286                     if (formKey) { 299                     if (formKey) {
287                         dataPost.data.form_key = formKey; 300                         dataPost.data.form_key = formKey;
288                     } 301                     }
289  302 
290                     var paramData = $.param(dataPost.data), 303                     var paramData = $.param(dataPost.data),
291                         url = dataPost.action + (paramData.length ? '?' + paramData : ''); 304                         url = dataPost.action + (paramData.length ? '?' + paramData : '');
292  305 
293                     e.stopPropagation(); 306                     e.stopPropagation();
294                     e.preventDefault(); 307                     e.preventDefault();
295                     
if (isAjax) {
 308 
    309                     if (isAjax && el.hasClass('towishlist')) {
    310                         submitFilterAction(url, true);
    311                     } else if (isAjax) {
296                         submitFilterAction(url); 312                         submitFilterAction(url);
297                     } 313                     else location.href = url;
298                     
else location.href = url;
    
299                 }); 314                 });
300             }) 315             })
    316         },
    317 
    318         //Selected attribute color after page load.
    319         selectedAttr: function () {
    320             var filterCurrent = $('.layered-filter-block-container .filter-current .items .item .filter-value');
    321 
    322             filterCurrent.each(function(){
    323                 var el         = $(this),
    324                     colorLabel = el.html(),
    325                     colorAttr  = $('.filter-options .filter-options-item .color .swatch-option-link-layered .swatch-option');
    326 
    327                 colorAttr.each(function(){
    328                     var elA = $(this);
    329                     if(elA.attr('data-option-label') === colorLabel && !elA.hasClass('selected')){
    330                         elA.addClass('selected');
    331                     }
    332                 });
    333             });
301         } 334         }
302     }); 335     });
303  336 
304     return $.mageplaza.layer; 337     return $.mageplaza.layer;
305 }); 338 });